<?php

// $Id$

require_once(TANGRA_MAIN_DIR.'form/guardable_form.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/text/form_field_text.class.php');
require_once(TANGRA_MAIN_DIR.'/form/static_html_form_generator.class.php');


class Menu_Item_Type_Form extends Guardable_Form {
	function __construct() {
		parent::__construct('menu_item_type', 'admin/modules/tangra_cms/menu/menu_item_types.php');

		$f_name = new Form_Field_Text('name', true, 255);
		$this->add_field($f_name);

		$f_hid = new Form_Field_Text('hid', true, 255);
		$f_hid->add_potential_error('invalid_hid');
		$f_hid->add_potential_error('duplicate_hid');
		$this->add_field($f_hid);

		$f_class_path = new Form_Field_Text('class_path', true, 255);
		$f_class_path->add_potential_error('file_not_exist');
		$this->add_field($f_class_path);

		$f_class_name = new Form_Field_Text('class_name', true, 255);
		$f_class_name->add_potential_error('invalid_class_name');
		$this->add_field($f_class_name);

		$f_page_edit_path = new Form_Field_Text('page_edit_path', true, 255);
		$f_page_edit_path->add_potential_error('file_not_exist');
		$this->add_field($f_page_edit_path);

		$f_capture_prefix = new Form_Field_Text('capture_prefix', false, 255);
		$this->add_field($f_capture_prefix);
	}


	public function generate_html() {
		$html_gen = new Static_HTML_Form_Generator($this, 'modules/form_html_tpl_static_ajax_metallic_en', 'en');
		$html_gen->create_default_tpl_maps();
		$html_gen->change_field_p_error_map_entry('class_path', 'file_not_exist', 'modules/tangra_cms/forms/en/menu_item_type/field_error_file_not_exist_en.tpl');
		$html_gen->change_field_p_error_map_entry('hid', 'invalid_hid', 'modules/tangra_cms/forms/en/menu_item_type/field_error_invalid_hid_en.tpl');
		$html_gen->change_field_p_error_map_entry('hid', 'duplicate_hid', 'modules/tangra_cms/forms/en/menu_item_type/field_error_duplicate_hid_en.tpl');
		$html_gen->change_field_p_error_map_entry('page_edit_path', 'file_not_exist', 'modules/tangra_cms/forms/en/menu_item_type/field_error_file_not_exist_en.tpl');
		$html_gen->change_field_p_error_map_entry('class_name', 'invalid_class_name', 'modules/tangra_cms/forms/en/menu_item_type/field_error_invalid_class_name_en.tpl');

		printbr('<pre>');
		printbr(htmlentities($html_gen->get_static_html()));
		printbr('</pre>');
	}
}
